package cn.kt.ipcount.chatgpt.service.impl;

import cn.kt.ipcount.chatgpt.domain.ChatgptInfo;
import cn.kt.ipcount.chatgpt.repository.ChatgptRepository;
import cn.kt.ipcount.chatgpt.service.ChatgptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by tao.
 * Date: 2023/2/10 14:16
 * 描述:
 */
@Service
public class ChatgptServiceImpl implements ChatgptService {
    @Autowired
    private ChatgptRepository chatgptRepository;

    @Override
    public List<ChatgptInfo> queryAll() {
        return chatgptRepository.findAll();
    }

    @Override
    public List<ChatgptInfo> queryYesterday(Date start, Date end) {
        return chatgptRepository.findAllByTimeIsBetween(start, end);
    }

    @Override
    public List<ChatgptInfo> findAllByOrderByIdDesc(Pageable pageable) {
        return chatgptRepository.findAllByOrderByIdDesc(pageable);
    }

    @Override
    public ChatgptInfo save(ChatgptInfo chatgptInfo) {
        return chatgptRepository.save(chatgptInfo);
    }
}
